﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Kargo3504
{
    public partial class FrmLogin : Form
    {
        public FrmLogin()
        {
            InitializeComponent();
        }
        bool KapatOK = false;
        private void btnGirisYap_Click(object sender, EventArgs e)
        {
            DBBaglantiDataContext db = new DBBaglantiDataContext();
            
                var srogu = (from x in db.Kullanicilars where x.KullaniciAdi == txtKullaniciAdi.Text && x.KullaniciSifresi == txtSifre.Text && x.KullaniciAktifMi == true select x).FirstOrDefault();

                if (srogu == null)
                {
                    MessageBox.Show("Geçersiz Bilgi");
                }
                else
                {
                    FrmAnaForm.GirisYapanKullanici = srogu;
                    KapatOK = true;
                    this.Close();
                }
            
        }

        private void FrmLogin_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!KapatOK)
            {
                Environment.Exit(0);
            }
        }
    }
}
